Fix lines_match test for matching process output
authorAlex Crichton <alex@alexcrichton.com>
Fri, 31 Oct 2014 18:17:29 +0000 (11:17 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 5 Nov 2014 19:37:34 +0000 (11:37 -0800)
tests/support/mod.rs
tests/test_cargo_bench.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_old_custom_build.rs
tests/test_cargo_publish.rs
tests/test_cargo_test.rs

index 544e9800df2598b194a639fd9a56eb069ee967ef..ff61bb06f199f7dcbfbb98e2e99fc8604b136a46 100644 (file)
@@ -347,13 +347,13 @@ impl Execs {
 fn lines_match(expected: &str, mut actual: &str) -> bool {
     for part in expected.split_str("[..]") {
         match actual.find_str(part) {
-            Some(i) => actual = actual.slice_from(i),
+            Some(i) => actual = actual.slice_from(i + part.len()),
             None => {
                 return false
             }
         }
     }
-    return true;
+    actual.len() == 0 || expected.ends_with("[..]")
 }
 
 struct ZipAll<T, I1, I2> {
index 5fec4ec0761fc0333a2e1cf59f65d0b977cb5c94..67a72b195118466369d2a3270279313fb04f94bc 100644 (file)
@@ -38,7 +38,7 @@ test!(cargo_bench_simple {
     assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
         execs().with_stdout(format!("\
 {} foo v0.5.0 ({})
-{} target[..]release[..]foo
+{} target[..]release[..]foo-[..]
 
 running 1 test
 test bench_hello ... bench:         0 ns/iter (+/- 0)
@@ -175,7 +175,7 @@ test!(cargo_bench_failing_test {
     assert_that(p.process(cargo_dir().join("cargo")).arg("bench"),
         execs().with_stdout(format!("\
 {} foo v0.5.0 ({})
-{} target[..]release[..]foo
+{} target[..]release[..]foo-[..]
 
 running 1 test
 test bench_hello ... ",
@@ -233,7 +233,7 @@ test bin_bench ... bench:         0 ns/iter (+/- 0)
 
 test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
 
-{running} target[..]release[..]foo
+{running} target[..]release[..]foo-[..]
 
 running 1 test
 test lib_bench ... bench:         0 ns/iter (+/- 0)
@@ -426,7 +426,7 @@ test!(pass_through_command_line {
                 execs().with_status(0)
                        .with_stdout(format!("\
 {compiling} foo v0.0.1 ({dir})
-{running} target[..]release[..]foo
+{running} target[..]release[..]foo-[..]
 
 running 1 test
 test bar ... bench:         0 ns/iter (+/- 0)
@@ -441,7 +441,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
                 execs().with_status(0)
                        .with_stdout(format!("\
 {compiling} foo v0.0.1 ({dir})
-{running} target[..]release[..]foo
+{running} target[..]release[..]foo-[..]
 
 running 1 test
 test foo ... bench:         0 ns/iter (+/- 0)
index 2e17745538d867e876d0330fc0a21596d173b358..11c50b20faba17e592c745ad65804bdd005a2454 100644 (file)
@@ -216,7 +216,7 @@ test!(cargo_compile_with_warnings_in_a_dep_package {
         .with_stderr("\
 [..]warning: function is never used: `dead`[..]
 [..]fn dead() {}
-
+[..]^~~~~~~~~~~~
 "));
 
     assert_that(&p.bin("foo"), existing_file());
index 321dd8167081e1ea1e3aebe95558f91431b8179a..63a8081f2ef803672e93dad199c58c474b9f7a02 100644 (file)
@@ -149,7 +149,7 @@ test!(old_custom_build_failure {
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(format!("\
 warning: the old build command has been deprecated\n\
-Failed to run custom build command for `foo v0.5.0 ({dir})
+Failed to run custom build command for `foo v0.5.0 ({dir})`
 Process didn't exit successfully: `{}` (status=101)\n\
 --- stderr\n\
 task '<main>' panicked at 'nope', {filename}:2\n\
@@ -213,7 +213,7 @@ test!(old_custom_second_build_failure {
     assert_that(p.cargo_process("build"),
                 execs().with_status(101).with_stderr(format!("\
 warning: the old build command has been deprecated\n\
-Failed to run custom build command for `foo v0.5.0 ({dir})
+Failed to run custom build command for `foo v0.5.0 ({dir})`
 Process didn't exit successfully: `{}` (status=101)\n\
 --- stderr\n\
 task '<main>' panicked at 'nope', {filename}:2\n\
index bf291d6fbf8965e33f42da50855e1c5d97678ede..bca369b6797e1aa3111f3c1c42c98ca8003a9f22 100644 (file)
@@ -90,7 +90,7 @@ test!(git_deps {
 
     assert_that(p.cargo_process("publish").arg("-v").arg("--no-verify"),
                 execs().with_status(101).with_stderr("\
-all dependencies must come from the same registry
+all dependencies must come from the same registry.
 dependency `foo` comes from git://path/to/nowhere instead
 "));
 })
@@ -118,7 +118,7 @@ test!(path_dependency_no_version {
     assert_that(p.cargo_process("publish"),
                 execs().with_status(101).with_stderr("\
 all path dependencies must have a version specified when being uploaded \
-to the registry
+to the registry.
 dependency `bar` does not specify a version
 "));
 })
index 450ae4f1a28bf1db537c086c44691f1d6eab8014..3b25ae4534a5ca8cbf9660a355877b62e0f38d04 100644 (file)
@@ -36,7 +36,7 @@ test!(cargo_test_simple {
     assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
         execs().with_stdout(format!("\
 {} foo v0.5.0 ({})
-{} target[..]foo
+{} target[..]foo-[..]
 
 running 1 test
 test test_hello ... ok
@@ -127,7 +127,7 @@ test!(cargo_test_failing_test {
     assert_that(p.process(cargo_dir().join("cargo")).arg("test"),
         execs().with_stdout(format!("\
 {} foo v0.5.0 ({})
-{} target[..]foo
+{} target[..]foo-[..]
 
 running 1 test
 test test_hello ... FAILED
@@ -198,7 +198,7 @@ test bin_test ... ok
 
 test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 
-{running} target[..]foo
+{running} target[..]foo[..]
 
 running 1 test
 test lib_test ... ok
@@ -413,7 +413,7 @@ test!(pass_through_command_line {
                 execs().with_status(0)
                        .with_stdout(format!("\
 {compiling} foo v0.0.1 ({dir})
-{running} target[..]foo
+{running} target[..]foo-[..]
 
 running 1 test
 test bar ... ok
@@ -435,7 +435,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
                 execs().with_status(0)
                        .with_stdout(format!("\
 {compiling} foo v0.0.1 ({dir})
-{running} target[..]foo
+{running} target[..]foo-[..]
 
 running 1 test
 test foo ... ok